﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using WebeTerm.Common;

namespace WebeTerm.Web
{
    public abstract class BasePage:Page
    {
        /// <summary>
        /// 当前用户ID
        /// </summary>
        public Guid? EmployeeId { get { return Session[@"EmployeeId"] == null ? new Guid(@"B97B5542-445E-42AC-8FE4-EA732E8FB4F5") : Utility.ParseGuidNull(Session[@"EmployeeId"].ToString()); } set { Session[@"EmployeeId"] = value; } }


        /// <summary>
        /// 当前用户公司ID
        /// </summary>
        public Guid? CompanyId { get { return Session[@"CompanyId"] == null ? new Guid(@"EAF23A44-6974-400C-8303-7B05224254EA") : Utility.ParseGuidNull(Session[@"CompanyId"].ToString()); } set { Session[@"CompanyId"] = value; } }

        /// <summary>
        /// 是否需要验证登录
        /// </summary>
        protected virtual bool RequirePermission { get { return true; } }

        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event to initialize the page.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            if (RequirePermission && !EmployeeId.HasValue) {
                Response.Redirect(@"~/Account/Login.aspx");
            }
        }

    }


}